package com.it.gmall.realtime.util;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.Properties;

/**
 * desc :读取配置文件工具类
 *
 * @author : code1997
 * @date :2021-01-2021/1/27 23:21
 */
public class PropertiesUtil {

    /**
     * 读取路径位置的文件
     *
     * @param fileName :要加载的配置文件的名字
     * @return ：properties对象
     */
    public static Properties load(String fileName) {
        Properties properties = new Properties();
        try {
            properties.load(new InputStreamReader(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName))
                    , StandardCharsets.UTF_8));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return properties;
    }


}
